Ext
		.onReady(function() {
			Ext.QuickTips.init();
			Ext.form.Field.prototype.msgTarget = 'under';
			var schedule = new Ext.data.Record.create( [ {
				name : 'scheduleId',
				type : 'int'
			}, {
				name : 'classId',
				type : 'int'
			}, {
				name : 'className',
				type : 'string'
			}, {
				name : 'classroomId',
				type : 'int'
			}, {
				name : 'classroomName',
				type : 'string'
			}, {
				name : 'courseId',
				type : 'int'
			}, {
				name : 'courseName',
				type : 'string'
			}, {
				name : 'teacherId',
				type : 'int'
			}, {
				name : 'teacherName',
				type : 'string'
			}, {
				name : 'totalTime',
				type : 'int'
			}, {
				name : 'weekTime',
				type : 'int'
			}, ]);

			var schedulestore;
			function getData(val) {
				var url = "/schedule/querySchedule"
						//+ encodeURI(encodeURI(val));
				schedulestore = new Ext.data.Store( {
					id : "scheduleId",
					proxy : new Ext.data.HttpProxy( {
						url : url
					}),
					reader : new Ext.data.JsonReader( {
						totalProperty : 'totalProperty',
						root : 'root'
					}, schedule),
					remoteSort : true
				});
				if (val != undefined) {
					grid.reconfigure(schedulestore, cols);
				}
				schedulestore.load( {
					params : {
						start : 0,
						limit : 15
					}
				});
			}
			;
			getData();

			var sm = new Ext.grid.CheckboxSelectionModel();

			var cols = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(),
					sm,  {
						header : '班级名称',
						dataIndex : 'className'
					}, {
						header : '课程名称',
						dataIndex : 'courseName'
					}, {
						header : '教师名称',
						dataIndex : 'teacherName'
					}, {
						header : '教室名称',
						dataIndex : 'classroomName'
					}, {
						header : '总课时名称',
						dataIndex : 'totalTime'
					}, {
						header : '周课时',
						dataIndex : 'weekTime'
					} ]);
			cols.defaultSortable = true;

			

			var grid = new Ext.grid.GridPanel(
					{
						title : '教学计划信息列表',
						region : 'center',
						buttonAlign : "left",
						listeners : {
							"rowdblclick" : function(grid, rowIndex, e) {
								
							}
						},
						buttons : [
								{
									text : "新增",
									listeners : {
										click : function() {
											var newwin = window.showModalDialog("queryScheduleA.jsp", "", "dialogTop:200px;dialogWidth:1500px;dialogHeight:500px;location=no; dialogLeft:300px;modal=yes");
										}
									}
								},
								{
									text : "删除",
									listeners : {
										click : function() {
											var ids = "";
											var records = grid
													.getSelectionModel()
													.getSelections();
											if ("" == records) {
												Ext.MessageBox.alert("提示",
														"请选择要删除的记录");
											} else {
												for ( var i = 0; i < records.length; i++) {

													ids += records[i]
															.get("scheduleId")
															+ ",";

												}
												;
												Ext.MessageBox
														.confirm(
																"确认删除",
																"确认删除所选数据？",
																function(button) {
																	if (button == "yes") {
																		Ext.Ajax
																				.request( {
																					url : '/schedule/deleteSchedule',
																					params : {
																						ids : ids
																					},
																					method : 'POST',
																					success : function(
																							form,
																							action) {
																						Ext.Msg
																								.alert(
																										"系统消息",
																										"删除成功",
																										function() {
																											grid
																													.resumeEvents();
																											schedulestore
																													.reload();
																										},
																										this);
																					},
																					failure : function(
																							form,
																							action) {
																						Ext.Msg
																								.alert(
																										'系统消息',
																										"删除失败");
																						grid
																								.resumeEvents();
																						schedulestore
																								.reload();
																					},

																					scope : this
																				});
																	}
																}, this);
											}
										}
									}

								} ],
						loadMask : true,
						store : schedulestore,
						cm : cols,
						sm : sm,
						viewConfig : {
							forceFit : true
						},
						bbar : new Ext.PagingToolbar( {
							store :schedulestore,
							pageSize : 15,//页大小 
							displayInfo : true,//是否显示displayMsg 
							displayMsg : "本页显示第{0}条到第{1}条的记录,一共{2}条",
							emptyMsg : "没有记录"//如果没有记录，则显示该文本 
						})

					});

			var viewport = new Ext.Viewport( {
				layout : 'border',
				title : '列表',
				items : [ grid, {
					region : 'south',
					contentEl : 'foot'
				} ]
			});
		});